﻿using System;
using UnityEngine;

// Token: 0x02000395 RID: 917
public class TagTextUtility
{
	// Token: 0x0600169D RID: 5789 RVA: 0x00096B88 File Offset: 0x00094D88
	public static float Load_Float(TagText.Attribute attribute, int id = 0)
	{
		if (id >= attribute.vals.Count)
		{
			return 0f;
		}
		return float.Parse(attribute.vals[id]);
	}

	// Token: 0x0600169E RID: 5790 RVA: 0x00096BB4 File Offset: 0x00094DB4
	public static float Load_Float(TagText.Element element, string attribute, int id = 0)
	{
		if (element.Attributes.ContainsKey(attribute))
		{
			return TagTextUtility.Load_Float(element.Attributes[attribute], id);
		}
		return 0f;
	}

	// Token: 0x0600169F RID: 5791 RVA: 0x00096BE0 File Offset: 0x00094DE0
	public static bool Load_Float(ref float val, TagText.Element element, string attribute, int id = 0)
	{
		if (element.Attributes.ContainsKey(attribute))
		{
			val = TagTextUtility.Load_Float(element.Attributes[attribute], id);
			return true;
		}
		return false;
	}

	// Token: 0x060016A0 RID: 5792 RVA: 0x00096C0C File Offset: 0x00094E0C
	public static bool Load_Bool(TagText.Attribute attribute, int id = 0)
	{
		if (id >= attribute.vals.Count)
		{
			return false;
		}
		bool result = false;
		try
		{
			result = bool.Parse(attribute.vals[id]);
		}
		catch (Exception arg)
		{
			GlobalData.Debug_LogError(attribute.vals[id] + ":" + arg);
		}
		return result;
	}

	// Token: 0x060016A1 RID: 5793 RVA: 0x00096C78 File Offset: 0x00094E78
	public static bool Load_Bool(TagText.Element element, string attribute, int id = 0)
	{
		return element.Attributes.ContainsKey(attribute) && TagTextUtility.Load_Bool(element.Attributes[attribute], id);
	}

	// Token: 0x060016A2 RID: 5794 RVA: 0x00096CA0 File Offset: 0x00094EA0
	public static bool Load_Bool(ref bool val, TagText.Element element, string attribute, int id = 0)
	{
		if (element.Attributes.ContainsKey(attribute))
		{
			val = TagTextUtility.Load_Bool(element.Attributes[attribute], id);
			return true;
		}
		return false;
	}

	// Token: 0x060016A3 RID: 5795 RVA: 0x00096CCC File Offset: 0x00094ECC
	public static string Load_String(TagText.Attribute attribute, int id = 0)
	{
		if (id == -1)
		{
			return attribute.valOriginal;
		}
		if (id < attribute.vals.Count)
		{
			return attribute.vals[id];
		}
		return string.Empty;
	}

	// Token: 0x060016A4 RID: 5796 RVA: 0x00096D00 File Offset: 0x00094F00
	public static string Load_String(TagText.Element element, string attribute, int id = 0)
	{
		if (element.Attributes.ContainsKey(attribute))
		{
			return TagTextUtility.Load_String(element.Attributes[attribute], id);
		}
		return null;
	}

	// Token: 0x060016A5 RID: 5797 RVA: 0x00096D28 File Offset: 0x00094F28
	public static bool Load_String(ref string str, TagText.Element element, string attribute, int id = 0)
	{
		if (element.Attributes.ContainsKey(attribute))
		{
			str = TagTextUtility.Load_String(element.Attributes[attribute], id);
			return true;
		}
		return false;
	}

	// Token: 0x060016A6 RID: 5798 RVA: 0x00096D54 File Offset: 0x00094F54
	public static Vector3 Load_Vector3(TagText.Attribute attribute, int id = 0)
	{
		return new Vector3(TagTextUtility.Load_Float(attribute, id), TagTextUtility.Load_Float(attribute, id + 1), TagTextUtility.Load_Float(attribute, id + 2));
	}

	// Token: 0x060016A7 RID: 5799 RVA: 0x00096D74 File Offset: 0x00094F74
	public static Vector3 Load_Vector3(TagText.Element element, string attribute, int id = 0)
	{
		if (element.Attributes.ContainsKey(attribute))
		{
			return TagTextUtility.Load_Vector3(element.Attributes[attribute], id);
		}
		return new Vector3(0f, 0f, 0f);
	}

	// Token: 0x060016A8 RID: 5800 RVA: 0x00096DB0 File Offset: 0x00094FB0
	public static bool Load_Vector3(ref Vector3 vec, TagText.Element element, string attribute, int id = 0)
	{
		if (element.Attributes.ContainsKey(attribute))
		{
			vec = TagTextUtility.Load_Vector3(element.Attributes[attribute], id);
			return true;
		}
		return false;
	}

	// Token: 0x060016A9 RID: 5801 RVA: 0x00096DE0 File Offset: 0x00094FE0
	public static void Save_Vector3(TagText.Element element, string attribute, Vector3 vec)
	{
		string val = string.Concat(new object[]
		{
			vec.x,
			",",
			vec.y,
			",",
			vec.z
		});
		element.AddAttribute(attribute, val);
	}

	// Token: 0x060016AA RID: 5802 RVA: 0x00096E40 File Offset: 0x00095040
	public static Vector2 Load_Vector2(TagText.Attribute attribute, int id = 0)
	{
		return new Vector2(TagTextUtility.Load_Float(attribute, id), TagTextUtility.Load_Float(attribute, id + 1));
	}

	// Token: 0x060016AB RID: 5803 RVA: 0x00096E58 File Offset: 0x00095058
	public static Vector2 Load_Vector2(TagText.Element element, string attribute, int id = 0)
	{
		if (element.Attributes.ContainsKey(attribute))
		{
			return TagTextUtility.Load_Vector2(element.Attributes[attribute], id);
		}
		return new Vector2(0f, 0f);
	}

	// Token: 0x060016AC RID: 5804 RVA: 0x00096E90 File Offset: 0x00095090
	public static bool Load_Vector2(ref Vector2 vec, TagText.Element element, string attribute, int id = 0)
	{
		if (element.Attributes.ContainsKey(attribute))
		{
			vec = TagTextUtility.Load_Vector2(element.Attributes[attribute], id);
			return true;
		}
		return false;
	}

	// Token: 0x060016AD RID: 5805 RVA: 0x00096EC0 File Offset: 0x000950C0
	public static void Save_Vector2(TagText.Element element, string attribute, Vector2 vec)
	{
		string val = vec.x + "," + vec.y;
		element.AddAttribute(attribute, val);
	}

	// Token: 0x060016AE RID: 5806 RVA: 0x00096EF8 File Offset: 0x000950F8
	public static Color Load_Color(TagText.Attribute attribute, int id = 0)
	{
		Color result = default(Color);
		result.r = TagTextUtility.Load_Float(attribute, id);
		result.g = TagTextUtility.Load_Float(attribute, id + 1);
		result.b = TagTextUtility.Load_Float(attribute, id + 2);
		if (attribute.vals.Count >= 4)
		{
			result.a = TagTextUtility.Load_Float(attribute, id + 3);
		}
		else
		{
			result.a = 1f;
		}
		return result;
	}

	// Token: 0x060016AF RID: 5807 RVA: 0x00096F70 File Offset: 0x00095170
	public static Color Load_Color(TagText.Element element, string attribute, int id = 0)
	{
		if (element.Attributes.ContainsKey(attribute))
		{
			return TagTextUtility.Load_Color(element.Attributes[attribute], id);
		}
		return new Color(0f, 0f, 0f);
	}

	// Token: 0x060016B0 RID: 5808 RVA: 0x00096FAC File Offset: 0x000951AC
	public static bool Load_Color(ref Color vec, TagText.Element element, string attribute, int id = 0)
	{
		if (element.Attributes.ContainsKey(attribute))
		{
			vec = TagTextUtility.Load_Color(element.Attributes[attribute], id);
			return true;
		}
		return false;
	}

	// Token: 0x060016B1 RID: 5809 RVA: 0x00096FDC File Offset: 0x000951DC
	public static void Save_Color(TagText.Element element, string attribute, Color color)
	{
		string val = string.Concat(new object[]
		{
			color.r,
			",",
			color.g,
			",",
			color.b,
			",",
			color.a
		});
		element.AddAttribute(attribute, val);
	}

	// Token: 0x060016B2 RID: 5810 RVA: 0x00097054 File Offset: 0x00095254
	public static Quaternion Load_Quaternion(TagText.Attribute attribute, int id = 0)
	{
		return new Quaternion(TagTextUtility.Load_Float(attribute, id), TagTextUtility.Load_Float(attribute, id + 1), TagTextUtility.Load_Float(attribute, id + 2), TagTextUtility.Load_Float(attribute, id + 3));
	}

	// Token: 0x060016B3 RID: 5811 RVA: 0x00097080 File Offset: 0x00095280
	public static Quaternion Load_Quaternion(TagText.Element element, string attribute, int id = 0)
	{
		if (element.Attributes.ContainsKey(attribute))
		{
			return TagTextUtility.Load_Quaternion(element.Attributes[attribute], id);
		}
		return Quaternion.identity;
	}

	// Token: 0x060016B4 RID: 5812 RVA: 0x000970AC File Offset: 0x000952AC
	public static bool Load_Quaternion(ref Quaternion qtn, TagText.Element element, string attribute, int id = 0)
	{
		if (element.Attributes.ContainsKey(attribute))
		{
			qtn = TagTextUtility.Load_Quaternion(element.Attributes[attribute], id);
			return true;
		}
		return false;
	}

	// Token: 0x060016B5 RID: 5813 RVA: 0x000970DC File Offset: 0x000952DC
	public static void Save_Quaternion(TagText.Element element, string attribute, Quaternion qtn)
	{
		string val = string.Concat(new object[]
		{
			qtn.x,
			",",
			qtn.y,
			",",
			qtn.z,
			",",
			qtn.w
		});
		element.AddAttribute(attribute, val);
	}

	// Token: 0x060016B6 RID: 5814 RVA: 0x00097154 File Offset: 0x00095354
	public static bool Check_Attribute(TagText.Element element, string attribute)
	{
		return element.Attributes.ContainsKey(attribute);
	}
}
